package com.example.ioc.config;

import com.example.ioc.service.impl.UserServiceImpl;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

        RootBeanDefinition definition = new RootBeanDefinition();
        definition.setBeanClass(UserServiceImpl.class);

        registry.registerBeanDefinition("userService", definition);

        registry.registerBeanDefinition("userDao", new RootBeanDefinition("com.example.ioc.dao.impl.UserDaoImpl"));

    }

}
